import registnet.dao.CourseOffering;
import registnet.dao.CourseOfferingPeer;
import registnet.dao.UnitPeer;

String _office = "ICS";

private class CourseOfferingRenderer implements RowRenderer  {
	public void render(Row row, java.lang.Object data) {
		new Label(data[0]).setParent(row);
		new Label(data[1]).setParent(row);
		new Label(data[2]).setParent(row);
		new Label(data[3]).setParent(row);
		new Label(data[4]).setParent(row);
		new Label(data[5]).setParent(row);
		new Label(data[6]).setParent(row);
	}
}

void retrieveCourseOfferings(){
	List courseOfferings = new CourseOfferingPeer().getCourseOfferingsByUnit(new  UnitPeer().getUnitId(_office));
	String[][] listModel = new String[courseOfferings.size()][7];

	for(i = 0; i < courseOfferings.size(); i++){
		CourseOffering courseOffering = courseOfferings.get(i);
		listModel[i][0] = courseOffering.getCourse().getCourseCode();
		listModel[i][1] = courseOffering.getCourseOfferingName();
		if(courseOffering.getLaboratoryDay() != null && courseOffering.getLaboratoryDay().length() != 0){
			listModel[i][2] = courseOffering.getLaboratoryDay();
			listModel[i][3] = courseOffering.getLaboratoryTime();
			listModel[i][4] = courseOffering.getLaboratoryRoom();
			listModel[i][5] = courseOffering.getLaboratoryInstructor();
		}
		else if(courseOffering.getRecitationDay() != null && courseOffering.getRecitationDay().length() != 0){
			listModel[i][2] = courseOffering.getRecitationDay();
			listModel[i][3] = courseOffering.getRecitationTime();
			listModel[i][4] = courseOffering.getRecitationRoom();
			listModel[i][5] = courseOffering.getRecitationInstructor();
		}
		else{
			listModel[i][2] = courseOffering.getLectureDay();
			listModel[i][3] = courseOffering.getLectureTime();
			listModel[i][4] = courseOffering.getLectureRoom();
			listModel[i][5] = courseOffering.getLectureInstructor();
		}
		listModel[i][6] = courseOffering.getStudentCount().toString();
	}
	
	ListModel strset = new SimpleListModel(listModel);
	course_offering_g.setModel(strset);
	course_offering_g.setRowRenderer(new CourseOfferingRenderer());
	
}
